import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class PGGenerate {
    public static void main(String[] args) {
        FastAutoGenerator.create(new DataSourceConfig.Builder("jdbc:postgresql://10.196.174.39:5432/mes_idg?currentSchema=sfj_slice",
                        "a_appconnect", "a_appconnect@1234").schema("slice_sfj"))
                .globalConfig(builder -> {
                    builder.author("YingBo.Dai") // 设置作者
                            .disableOpenDir()
//                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("E:\\workspace\\moss\\moss-service-mes\\moss-service-mes-sfj-kitting\\moss-service-mes-sfj-kitting-server\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.lenovo.moss.sfj.kitting.server") // 设置父包名
//                            .moduleName("kitting.server") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "E:\\workspace\\moss\\moss-service-mes\\moss-service-mes-sfj-kitting\\moss-service-mes-sfj-kitting-server\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("kit_category","kit_material","kit_bom","kit_uwip","kit_ds_raw","kit_ds_order","kit_download") // 设置需要生成的表名
                            .addTablePrefix("t_", "c_")
                            .controllerBuilder().enableRestStyle()
                            .mapperBuilder().enableMapperAnnotation()
//                            .entityBuilder()
                            .entityBuilder().enableLombok()
                    ; // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
